package com.lablzh.gdxy.repository.course;

import com.lablzh.gdxy.entity.course.CourseApply;
import com.lablzh.gdxy.entity.design.DesignApply;
import com.lablzh.gdxy.repository.StudentID;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface CourseApplyRepository extends JpaRepository<CourseApply,Integer> {
    CourseApply findByStudentUsernameAndCourseID(String studentUsername, Integer projectID);

    List<CourseApply> findAllByTeacherAndCourseID(String username, Integer id, Sort sort);

    List<CourseApply> findAllByStudentUsername(String username);
    @Modifying
    @Transactional
    @Query("update CourseApply set status=?2 where id=?1")
    int updateStatusById(Integer id, String status);

    List<StudentID>  findAllByStatusAndCollegeAndGrade(String status, String college, String grade);

    List<StudentID> findAllByStatusAndCollegeAndMajorAndGrade(String status, String college, String major, String grade);

    void deleteAllByCourseID(Integer id);

    List<CourseApply> findAllByCourseID(Integer id);

}
